/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gerenciadorfinanceiro.controller.resources;

import gerenciadorfinanceiro.controller.resources.OutcomeDAO;
import gerenciadorfinanceiro.database.resources.Outcome;
import gerenciadorfinanceiro.database.resources.User;
import java.util.List;
import org.springframework.orm.jpa.support.JpaDaoSupport;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author eduardo
 */

public class OutcomeDAOImpl extends JpaDaoSupport implements OutcomeDAO {

    public List getAllOucomes(User u, int month, int year) {
        return this.getJpaTemplate().find("select o from Outcome o where o.owner = ? and month(expirationData) = ? and year(expirationData) = ?", u, new Integer(month), new Integer(year));
    }

    public void gravaOutcome(Outcome o) {
        this.getJpaTemplate().persist(o);
        //this.getJpaTemplate().flush();
        return;
    }

}
